
// 补零
export function addZero(num) {
    return num > 10 ? num : '0' + num
}
// 获取当前时间
export function getNowDate() {
    var myDate = new Date;
    var year = myDate.getFullYear(); //获取当前年
    var mon = myDate.getMonth() + 1; //获取当前月
    var date = myDate.getDate(); //获取当前日
    var hours = myDate.getHours(); //获取当前小时
    var minutes = myDate.getMinutes(); //获取当前分钟
    var seconds = myDate.getSeconds(); //获取当前秒
    var now = year + "-" + addZero(mon) + "-" + addZero(date) + " " + addZero(hours) + ":" + addZero(minutes) + ":" + addZero(seconds);
    return now;
}
// 根据当前时间生成随机号码
export function createordernum(str) {
    const now = new Date()
    let month = now.getMonth() + 1
    let day = now.getDate()
    let hour = now.getHours()
    let minutes = now.getMinutes()
    let seconds = now.getSeconds()
    month = addZero(month)
    day = addZero(day)
    hour = addZero(hour)
    minutes = addZero(minutes)
    seconds = addZero(seconds)
    let orderCode = str + now.getFullYear().toString() + month.toString() + day + (Math.round(Math.random() * 1000)).toString();
    return orderCode;
    //基于年月日时分秒+随机数生成订单编号
}

